//
//  ZJBreakCell.m
//  这家测试项目
//
//  Created by IOS_DEVELOPER on 2017/6/28.
//  Copyright © 2017年 陈志凌. All rights reserved.
//

#import "ZJBreakCell.h"

@implementation ZJBreakCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.bmLabel.font = [UIFont systemFontOfSize:[Utils iphone5AutoScaleW:11.0f]];
    self.detailTitle.font = [UIFont systemFontOfSize:[Utils iphone5AutoScaleW:11.0f]];
    
}

-(void)setModel:(ZJBreakAccountModel *)model{
    _model = model;
    
    self.rightImg.hidden = NO;
    self.mainTitle.textColor = RGB(253, 200, 98);
//    self.rightImg.backgroundColor = [UIColor redColor];
    self.bgView.sd_layout.leftSpaceToView(self.contentView, 8).topSpaceToView(self.contentView, 8).rightSpaceToView(self.contentView, 8).autoHeightRatio(0);
    self.rightImg.sd_layout.topSpaceToView(self.bgView, 10).rightSpaceToView(self.bgView, 10).widthIs(65).heightIs(50);
    self.mainTitle.sd_layout.leftSpaceToView(self.bgView, 8).topSpaceToView(self.bgView, 27).rightSpaceToView(self.bgView, 8).heightIs(21);
    self.bmLabel.sd_layout.leftSpaceToView(self.bgView, 8).topSpaceToView(self.mainTitle, 9).rightSpaceToView(self.bgView, 8).autoHeightRatio(0);
    self.detailTitle.sd_layout.leftSpaceToView(self.bgView, 12).topSpaceToView(self.bmLabel, 0).rightSpaceToView(self.bgView, 10).autoHeightRatio(0);

    self.detailTitle.text = _model.content;
    
    self.bgView.backgroundColor = RGB(121, 83, 205);

    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:8];
    NSAttributedString *string = [[NSAttributedString alloc] initWithString:self.detailTitle.text attributes:@{NSForegroundColorAttributeName : RGB(195, 166, 255), NSParagraphStyleAttributeName: paragraphStyle}];
    self.detailTitle.attributedText = string;
    
    self.bmLabel.hidden = YES;
    if ([_model.only_sincere integerValue] == 1 && [_userModel.is_sincere integerValue] == 1) {

        self.bgView.backgroundColor = RGB(27, 27, 27);
        self.bmLabel.hidden = NO;
        self.mainTitle.text = @"VIP专享";
        self.mainTitle.textColor = RGB(253, 200, 98);
//        self.detailTitle.textColor = [Utils colorWithHexString:@"565656"];
        NSAttributedString *string = [[NSAttributedString alloc] initWithString:self.detailTitle.text attributes:@{NSForegroundColorAttributeName : [Utils colorWithHexString:@"565656"], NSParagraphStyleAttributeName: paragraphStyle}];
        self.detailTitle.attributedText = string;
        self.mainTitle.sd_layout.leftSpaceToView(self.bgView, 8).topSpaceToView(self.bgView, 20).rightSpaceToView(self.bgView, 8).heightIs(21);
        self.detailTitle.sd_layout.leftSpaceToView(self.bgView, 12).topSpaceToView(self.bmLabel, 16).rightSpaceToView(self.bgView, 10).autoHeightRatio(0);
    }
    if ([_model.only_sincere integerValue] == 1 && [_userModel.is_sincere integerValue] != 1) {

        self.bgView.backgroundColor = [Utils colorWithHexString:@"b9b9b9"];
        self.bmLabel.hidden = NO;
        self.mainTitle.text = @"VIP专享";
        self.mainTitle.textColor = RGB(235, 235, 235);
        self.bmLabel.textColor = RGB(235, 235, 235);
        self.rightImg.hidden = YES;
//        self.detailTitle.textColor = RGB(235, 235, 235);
        NSAttributedString *string = [[NSAttributedString alloc] initWithString:self.detailTitle.text attributes:@{NSForegroundColorAttributeName : RGB(235, 235, 235), NSParagraphStyleAttributeName: paragraphStyle}];
        self.detailTitle.attributedText = string;
        self.mainTitle.sd_layout.leftSpaceToView(self.bgView, 8).topSpaceToView(self.bgView, 20).rightSpaceToView(self.bgView, 8).heightIs(21);
        self.detailTitle.sd_layout.leftSpaceToView(self.bgView, 12).topSpaceToView(self.bmLabel, 16).rightSpaceToView(self.bgView, 10).autoHeightRatio(0);
    }
    
    self.detailTitle.isAttributedContent = YES;
    [self.bgView setupAutoHeightWithBottomViewsArray:@[self.rightImg,self.mainTitle,self.bmLabel,self.detailTitle] bottomMargin:16];
     [self setupAutoHeightWithBottomView:self.bgView bottomMargin:0];

    [self.contentView setNeedsLayout];
    [self.contentView layoutSubviews];
}
@end
